import Vue from "vue"
import Vuex from "vuex"

import menu from "./module/userRole"
Vue.use(Vuex)

const store = new Vuex.Store({
  state: {
    user:{},
    header:"",
    nodeMap: null,
    isEdit: null,
    selectedNode: {},
    selectFormItem: null,
    design:{},
  },
  mutations: {
    setUser(state, user) {
      state.user = user
    },
    setHeader(state,header){
      state.header = header
    },
    //流程图
    updateAvatar(state,avatar){
      state.user.avatar=avatar
    },
    selectedNode(state, val) {
      console.log(val)
      state.selectedNode = val
    },
    loadForm(state, val){
      state.design = val
    },
    setIsEdit(state, val){
      state.isEdit = val
    },
    setNodeMap(state,val){
      state.nodeMap = val
    },
    setWeight(state,val){
      state.selectedNode.weight=val
    },
    clear(state){
      state.user = {}
      state.header = ""
    }
  },
  modules: {
    namespaced: true,
    menu
  }
})

export default store;
